package com.party.core.service.analysis.impl;

import com.party.common.paging.Page;
import com.party.core.dao.read.analysis.StatisticsPageFlowReadDao;
import com.party.core.dao.write.analysis.StatisticsPageFlowWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.analysis.PageListOutput;
import com.party.core.model.analysis.StatisticsPageFlow;
import com.party.core.service.analysis.IStatisticsPageFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @program: party-temp
 * @description: 页面流程接口实现
 * @author: Huaqunhao
 * @create: 2018-08-01 11:59
 **/

@Service
public class StatisticsPageFlowService implements IStatisticsPageFlowService {

    @Autowired
    private StatisticsPageFlowReadDao statisticsPageFlowReadDao;
    @Autowired
    private StatisticsPageFlowWriteDao statisticsPageFlowWriteDao;

    @Override
    public String insert(StatisticsPageFlow statisticsPageFlow) {
        BaseModel.preInsert(statisticsPageFlow);
        boolean result = statisticsPageFlowWriteDao.insert(statisticsPageFlow);
        if (result) {
            return statisticsPageFlow.getId();
        }
        return null;
    }

    @Override
    public boolean update(StatisticsPageFlow statisticsPageFlow) {
        statisticsPageFlow.setUpdateDate(new Date());
        return statisticsPageFlowWriteDao.update(statisticsPageFlow);
    }

    @Override
    public boolean deleteLogic(String id) {
        return false;
    }

    @Override
    public boolean delete(String id) {
        return statisticsPageFlowWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public StatisticsPageFlow get(String id) {
        return statisticsPageFlowReadDao.get(id);
    }

    @Override
    public List<StatisticsPageFlow> listPage(StatisticsPageFlow statisticsPageFlow, Page page) {
        return statisticsPageFlowReadDao.listPage(statisticsPageFlow, page);
    }

    @Override
    public List<StatisticsPageFlow> list(StatisticsPageFlow statisticsPageFlow) {
        return statisticsPageFlowReadDao.listPage(statisticsPageFlow, null);
    }

    @Override
    public List<StatisticsPageFlow> batchList(Set<String> ids, StatisticsPageFlow statisticsPageFlow, Page page) {
        return null;
    }

    @Override
    public List<PageListOutput> analysisPage(Map<String, Object> params) {
        return statisticsPageFlowReadDao.analysisPage(params);
    }

    @Override
    public Integer analysisPageCount(Map<String, Object> params) {
        return statisticsPageFlowReadDao.analysisPageCount(params);
    }

    @Override
    public StatisticsPageFlow getNewFlow(String uniqueCode) {
        return statisticsPageFlowReadDao.getNewFlow(uniqueCode);
    }


    public Map<String, Object> getUvAndOutCount(Map<String, Object> params) {
        return statisticsPageFlowReadDao.getUvAndOutCount(params);
    }

    @Override
    public List<StatisticsPageFlow> queryPageBydate(String startDate, String endDate, int pageNum, int pageSize) {
        return statisticsPageFlowReadDao.queryPageBydate(startDate, endDate, pageNum, pageSize);
    }

    @Override
    public Integer queryPageTotalNumByDate(String startDate, String endDate) {
        return statisticsPageFlowReadDao.queryPageTotalNumByDate(startDate, endDate);
    }

    @Override
    public List<StatisticsPageFlow> queryPageFlowListByDate(String queryDate, Page page) {
        return statisticsPageFlowReadDao.queryPageFlowListByDate(queryDate, page);
    }

    @Override
    public int queryPageFlowCountByDate(String queryDate, Integer total) {
        return statisticsPageFlowReadDao.queryPageFlowCountByDate(queryDate, total);
    }

    @Override
    public void deletePageFlowByQueryDate(String queryDate, Integer total) {
        statisticsPageFlowWriteDao.deletePageFlowByQueryDate(queryDate, total);
    }
}
